<template>
  <div>
    <!--可以理解为一种容器-->
    <el-container>
      <!--边栏-->
      <el-aside :width="asideWidth">
        <!--logo-->
        <div style="height: 60px; line-height: 60px; font-size: 20px; display: flex; align-items: center; justify-content: center">
          <img src="@/assets/liblogo.png" style="width: 30px;" alt="">
          <span class="logo-title" v-show="!isCollapse">Library</span>
        </div>
        <!--菜单-->
        <el-menu router :collapse="isCollapse" :collapse-transition="false" background-color="#001529"
                 active-text-color="#fff" text-color="rgba(255, 255, 255, 0.65)" :default-active="$route.path"
                 style="border: none">
<!--          <el-menu-item index="/">-->
<!--            <i class="el-icon-s-home"></i>-->
<!--            <span slot="title">home</span>-->
<!--          </el-menu-item>-->
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-notebook-2"></i><span>Book</span></template>
            <!--书籍信息列表，在此实现书籍的增删改查            -->
            <el-menu-item index="/admin/book/info">info</el-menu-item>
            <el-menu-item index="/admin/book/record">record</el-menu-item>
            <!--获取邮件通知-->
<!--            <el-menu-item index="/notice">notice</el-menu-item>-->
          </el-submenu>
<!--          <el-submenu index="2">-->
<!--            <template slot="title"><i class="el-icon-user-solid"></i><span>user</span></template>-->
<!--            <el-menu-item index="/admin/user/info">info</el-menu-item>-->
<!--          </el-submenu>-->
        </el-menu>
      </el-aside>

      <el-container>
        <!--网页头部-->
        <el-header style="height: 60px; line-height: 60px; display: flex; align-items: center; box-shadow: 2px 0 6px rgba(0, 21, 41, .35);">
          <i :class="collapseIcon" @click="handleCollapse" style="font-size: 26px"></i>
          <el-breadcrumb separator="/" style="margin-left: 20px">
<!--            <el-breadcrumb-item :to="{ path: '/admin/book' }">book</el-breadcrumb-item>-->
<!--            <el-breadcrumb-item>book</el-breadcrumb-item>-->
<!--            <el-breadcrumb-item>info</el-breadcrumb-item>-->
<!--            <el-breadcrumb-item>record</el-breadcrumb-item>-->
<!--            <el-breadcrumb-item :to="{ path: '/' }">课程管理</el-breadcrumb-item>-->
          </el-breadcrumb>

          <div style="flex: 1; display: flex; justify-content: flex-end; align-items: center">
            <i class="el-icon-quanping" @click="handleFullScreen" style="font-size: 25px"></i>
            <el-dropdown placement="bottom" @command="handleCommand">
              <div style="display: flex; align-items: center; cursor: pointer">
<!--                <img src="el-icon-user-solid" alt="" style="width: 40px; height: 40px; margin: 0 5px">-->
                <i class="el-icon-user-solid"></i>
                <span>admin</span>
              </div>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>profile</el-dropdown-item>
                <el-dropdown-item command="exit">exit</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-header>

        <!--内容，每个页面只需要替换这一部分，菜单和头部都可以不变-->
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>

  </div>
</template>

<script>

export default {
  name: 'AdminHomeView',
  data() {
    return {
      isCollapse: false,
      asideWidth: '200px',
      collapseIcon: 'el-icon-s-fold'
    }
  },
  mounted() {

  },
  methods: {
    handleFullScreen() {
      document.documentElement.requestFullscreen()
    },
    handleCollapse() {
      this.isCollapse = !this.isCollapse
      this.asideWidth = this.isCollapse ? '64px' : '200px'
      this.collapseIcon = this.isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'
    },
    handleCommand(command) {
      if (command === 'exit') {
        window.sessionStorage.clear()
        this.$router.push('/login')
      }
    }
  }
}
</script>

<!--进行颜色，padding等样式的设计-->
<style>
.el-menu--inline, .el-menu-item {
  background-color: #000c17 !important;
}

.el-submenu__title {
  height: 40px !important;
  line-height: 40px !important;
  padding: 0 25px !important;
  transition: color 0s;
}
.el-menu--collapse .el-submenu__title {
  padding: 0 20px !important;
}
.el-submenu__title>i:nth-child(1) {
  margin-top: 2px;
}
.el-submenu__title>i.el-submenu__icon-arrow {
  margin-top: -5px;
}
.el-menu-item {
  min-width: 0 !important;
  width: calc(100% - 10px);
  margin: 5px;
  height: 40px !important;
  line-height: 40px !important;
  border-radius: 5px;
}
.el-menu--inline>.el-menu-item {
  padding-left: 50px !important;
}
.el-menu-item.is-active {
  background-color: dodgerblue !important;
}

.el-menu-item:hover {
  color: #fff !important;
}

.el-submenu__title:hover *, .el-submenu__title:hover {
  color: #fff !important;
}

.el-aside {
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
  background-color: #001529;
  color: #fff;
  min-height: 100vh;
  transition: width .3s;
}
.el-menu--collapse .el-tooltip {
  padding: 0 15px !important;
}
.logo-title {
  margin-left: 5px;
  transition: all .3s;
}
.el-menu {
  transition: all .3s;
}
</style>
